const connect = require('connect');
const qs = require('qs');
const url = require('url');

connect()
  .use(query)
  .use(function (req, res, next) {
    res.setHeader('Content-Type', 'application/json');
    res.end(JSON.stringify(req.query));
  })
  .listen(3000);

function query(req, res, next) {
  const query = url.parse(req.url).query;
  req.query = qs.parse(query);
  next();
}
